package com.cyanite.playlv2api.parsers.json;

import com.cyanite.playlv2api.types.Badge;

import org.json.JSONException;
import org.json.JSONObject;

public class BadgeParser extends AbstractParser<Badge> {

    @Override
    public Badge parse(JSONObject json) throws JSONException {

        Badge obj = new Badge();
        if (json.has("brief")) {
            obj.setDescription(json.getString("brief"));
        }
        if (json.has("photo")) {
            obj.setIcon(json.getString("photo"));
        }
        if (json.has("bid")) {
            obj.setId(json.getString("bid"));
        }
        if (json.has("name")) {
            obj.setName(json.getString("name"));
        }

        return obj;
    }
}